# -*- coding: utf-8 -*-
# @Date    : 2024/2/2
# @Author  : zouy
# @Email: 874112501@qq.com
"""https://www.geetest.com/demo/click-float.html

运行报错找不到模块，请以模块方式运行：python -m main.某验.某验三代.某验三代-click
"""
import random
import string
from urllib.parse import urljoin
import re
import os
import time
import json

import requests
from loguru import logger
import execjs

from main.某验.某验三代.util import get_track, DIR_PATH
from utils.click_crack import ClickCrack

with open(os.path.join(DIR_PATH, 'w3.js'), 'r', encoding='utf-8') as f:
    js_code = f.read()

ctx = execjs.compile(js_code)


def download_img(name, url):
    """下载验证码图片"""
    dir_path = os.path.dirname(os.path.abspath(__file__))
    resp = requests.get(url)
    pic_dir = os.path.join(dir_path, 'pic')
    if not os.path.exists(pic_dir):
        os.mkdir(pic_dir)
    with open(os.path.join(pic_dir, name), mode="wb") as f:
        f.write(resp.content)


def get_now():
    return str(int(time.time() * 1000))


def get_jsonp(text):
    jsonp_str = re.search(r"\((.*)\)", text, re.S).group(1)
    return json.loads(jsonp_str)


def get16randomStr(k):
    return ''.join(random.choices(string.digits + 'abcde', k=k))


def get_session():
    session = requests.Session()
    session.headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        # 'Accept': '*/*',
        # 'Accept-Language': 'zh-CN,zh;q=0.9',
        # 'Cache-Control': 'no-cache',
        # 'Connection': 'keep-alive',
        # 'Pragma': 'no-cache',
        'Referer': 'https://www.geetest.com/',
    }
    return session


def ft_register_slide(session):
    """1.1 注册获取challenge和gt"""
    url = 'https://www.geetest.com/demo/gt/register-click?t={}'.format(get_now())
    res = session.get(url)
    data = res.json()
    return data['gt'], data['challenge']


def ft_get_php(session, gt, challenge, random16Key):
    """1.2 第一个w,返回c(不变)[ 12, 58, 98, 36, 43, 95, 62, 15, 12 ]和s"""
    url = 'https://apiv6.geetest.com/get.php'
    w = ctx.call('generate_w1', gt, challenge, random16Key)
    params = {
        "gt": gt,
        "challenge": challenge,
        "lang": "zh-cn",
        "pt": "0",
        "client_type": "web",
        "w": w,
        "callback": "geetest_" + get_now()
    }
    res = session.get(url, params=params)
    data = get_jsonp(res.text)

    return data


def sc_ajax(session, gt, challenge, *, c, s, random16Key):
    """2.1 第二个w，返回{"result": "click"}
    Set-Cookie: GeeTestAjaxUser
    """
    url = "https://api.geevisit.com/ajax.php"
    track = get_track()
    w2_params = {
        'gt': gt,
        'challenge': challenge,
        'c': c,
        's': s,
        'track': track,
        'random16Key': random16Key
    }
    w = ctx.call('generate_w2', w2_params)
    params = {
        "gt": gt,
        "challenge": challenge,
        "lang": "zh-cn",
        "pt": "0",
        "client_type": "web",
        "w": w,
        "callback": "geetest_" + get_now()
    }

    res = session.get(url, params=params)
    data = get_jsonp(res.text)
    return data


def sc_get_php(session, gt, challenge):
    """2.2 返回验证码图片网址及新challenge值和s值和gct_path文件等
    set-cookie: GeeTestUser
    """
    url = "https://api.geevisit.com/get.php"
    params = {
        "is_next": "true",
        "type": "click",
        "gt": gt,
        "challenge": challenge,
        "lang": "zh-cn",
        "https": "true",
        "protocol": "https://",
        "offline": "false",
        "product": "float",
        "api_server": "api.geevisit.com",
        "isPC": "true",
        "autoReset": "true",
        "width": "100%",
        "callback": "geetest_" + get_now(),
    }
    res = session.get(url, params=params)
    data = get_jsonp(res.text)
    return data


def get_x():
    # import importlib
    with open(os.path.join(DIR_PATH, 'pic', 'click.jpg'), 'rb') as f:
        captcha_image = f.read()
    # module = importlib.import_module('4验证码.验证码工具代码.click_crack')
    # ClickCrack = getattr(module, 'ClickCrack')
    result = ClickCrack(bg=captcha_image).discern()
    return result


def gen_ca_list(point_list, dt_list):

    ca = []
    for idx, point in enumerate(point_list):
        if not idx:
            dt = dt_list[idx]
        else:
            dt = dt_list[idx] - dt_list[idx - 1]
        i = {
            'x': point[0],
            'y': point[1],
            't': 1,
            'dt': dt
        }
        ca.append(i)
    # ca.append({"x": 868, "y": 567, "t": 3, "dt": random.randint(500, 600)})
    ca.append({"x": 868, "y": 567, "t": 3, "dt": dt_list[-1] - dt_list[-2]})
    return ca


def update_track_dt(t, track_list):
    for i in track_list:
        if len(i) == 5:
            i[3] += t
        elif len(i) == 2:
            i[2] += t
        else:
            raise Exception(f'轨迹长度不是2和5：{len(i)}  {i}')


def td_ajax_php(session, gt, challenge, getphp_c, getphp_s, getphp_pic, random16Key):
    """3 .拖动滑块,返回validate"""

    t = int(time.time() * 1000)
    logger.info(f'{t=}')
    point_list = get_x()  # [[609, 208], [926, 525]]  '209_62,9762_9614'  this[$_BIJAk(323)];
    logger.info(f'{point_list=}')
    oo = 602.0499877929688
    gg = 205.94375610351562

    aa = 331.8500061035156

    point_list = [[round(x*aa/344+oo),round(y*aa/344+gg)]   for x,y in point_list]
    # aa = 344
    # point_radio = [[x / aa * 100, y / aa * 100] for x, y in point_list]
    point_radio = [[(x-oo) / aa * 100, (y-gg) / aa * 100] for x, y in point_list]

    point_str = ','.join([f'{round(x * 100)}_{round(y * 100)}' for x, y in point_radio])

    # point_list = [[round(x + oo), round(y + gg)] for x, y in point_list]
    dt_list = [
        random.randint(828, 838),
        random.randint(1309, 1320),
        random.randint(2090, 2100),
        random.randint(2690, 2700),
        random.randint(3235, 3242)
    ]
    logger.info(f'{dt_list=}')
    ca = gen_ca_list(point_list, dt_list)
    # click_track = gen_click_track(ca)

    click_track1 = [
        ['move', 818, 325, 0, 'pointermove'],
        ['move', 818, 325, 1, 'mousemove'],
        ['move', 819, 327, 16, 'pointermove'],
        ['move', 820, 327, 40, 'pointermove'],
        ['move', 822, 328, 80, 'pointermove'],
        ['move', 822, 327, 233, 'pointermove'],
        ['move', 822, 326, 240, 'pointermove'],
        ['move', 820, 325, 249, 'pointermove'],
        ['move', 818, 322, 255, 'pointermove'],
        ['move', 817, 321, 256, 'mousemove'],
        ['move', 816, 317, 264, 'pointermove'],
        ['move', 814, 314, 271, 'pointermove'],
        ['move', 813, 313, 272, 'mousemove'],
        ['move', 807, 307, 282, 'pointermove'],
        ['move', 799, 299, 288, 'pointermove'],
        ['move', 792, 293, 295, 'pointermove'],
        ['move', 785, 289, 304, 'pointermove'],
        ['move', 779, 287, 313, 'pointermove'],
        ['move', 773, 283, 320, 'pointermove'],
        ['move', 768, 280, 328, 'pointermove'],
        ['move', 764, 279, 336, 'pointermove'],
        ['move', 758, 277, 344, 'pointermove'],
        ['move', 758, 277, 345, 'mousemove'],
        ['move', 754, 276, 352, 'pointermove'],
        ['move', 749, 274, 360, 'pointermove'],
        ['move', 745, 274, 368, 'pointermove'],
        ['move', 743, 272, 376, 'pointermove'],
        ['move', 741, 272, 384, 'pointermove'],
        ['move', 738, 272, 392, 'pointermove'],
        ['move', 736, 272, 400, 'pointermove'],
        ['move', 734, 272, 407, 'pointermove'],
        ['move', 731, 272, 416, 'pointermove'],
        ['move', 728, 272, 423, 'pointermove'],
        ['move', 724, 272, 432, 'pointermove'],
        ['move', 720, 272, 439, 'pointermove'],
        ['move', 714, 272, 448, 'pointermove'],
        ['move', 710, 272, 456, 'pointermove'],
        ['move', 707, 272, 463, 'pointermove'],
        ['move', 703, 272, 472, 'pointermove'],
        ['move', 699, 272, 481, 'pointermove'],
        ['move', 697, 272, 487, 'pointermove'],
        ['move', 695, 273, 496, 'pointermove'],
        ['move', 694, 273, 504, 'pointermove'],
        ['move', 692, 273, 512, 'pointermove'],
        ['move', 690, 273, 544, 'pointermove'],
        ['move', 690, 273, 551, 'pointermove'],
        ['move', 689, 273, 552, 'mousemove'],
        ['move', 689, 273, 561, 'pointermove'],
        ['move', 687, 273, 567, 'pointermove'],
        ['move', 684, 273, 576, 'pointermove'],
        ['move', 680, 273, 583, 'pointermove'],
        ['move', 675, 274, 591, 'pointermove'],
        ['move', 673, 275, 599, 'pointermove'],
        ['move', 672, 275, 600, 'mousemove'],
        ['move', 670, 275, 608, 'pointermove'],
        ['move', 666, 277, 616, 'pointermove'],
        ['move', 664, 279, 623, 'pointermove'],
        ['move', 662, 279, 632, 'pointermove'],
        ['move', 660, 280, 640, 'pointermove'],
        ['move', 658, 280, 648, 'pointermove']
    ]
    update_track_dt(t, click_track1)
    # ['down', 658, 280, 755, 'pointerdown'],
    # ['up', 658, 280, 832, 'pointerup'],  # 184

    click_track2 = [
        ['move', 661, 282, 855, 'pointermove'],
        ['move', 666, 282, 863, 'pointermove'],
        ['move', 674, 283, 871, 'pointermove'],
        ['move', 679, 285, 879, 'pointermove'],
        ['move', 689, 285, 887, 'pointermove'],
        ['move', 702, 285, 895, 'pointermove'],
        ['move', 715, 285, 903, 'pointermove'],
        ['move', 729, 285, 911, 'pointermove'],
        ['move', 742, 285, 919, 'pointermove'],
        ['move', 754, 285, 927, 'pointermove'],
        ['move', 766, 286, 936, 'pointermove'],
        ['move', 779, 287, 944, 'pointermove'],
        ['move', 788, 287, 952, 'pointermove'],
        ['move', 798, 287, 959, 'pointermove'],
        ['move', 806, 289, 967, 'pointermove'],
        ['move', 805, 289, 968, 'mousemove'],
        ['move', 811, 290, 976, 'pointermove'],
        ['move', 817, 290, 983, 'pointermove'],
        ['move', 820, 290, 992, 'pointermove'],
        ['move', 822, 290, 999, 'pointermove'],
        ['move', 823, 290, 1008, 'pointermove'],
        ['move', 825, 290, 1015, 'pointermove'],
        ['move', 826, 290, 1024, 'pointermove'],
        ['move', 826, 291, 1032, 'pointermove'],
        ['move', 828, 291, 1056, 'pointermove'],
    ]
    update_track_dt(t, click_track2)
    # ['down', 828, 291, 1263, 'pointerdown'],
    # ['up', 828, 291, 1311, 'pointerup'],  # 255

    click_track3 = [
        ['move', 828, 291, 1359, 'pointermove'],
        ['move', 828, 292, 1368, 'pointermove'],
        ['move', 828, 294, 1375, 'pointermove'],
        ['move', 828, 293, 1376, 'mousemove'],
        ['move', 826, 296, 1383, 'pointermove'],
        ['move', 822, 299, 1392, 'pointermove'],
        ['move', 816, 303, 1401, 'pointermove'],
        ['move', 808, 310, 1407, 'pointermove'],
        ['move', 799, 317, 1415, 'pointermove'],
        ['move', 792, 324, 1423, 'pointermove'],
        ['move', 784, 334, 1430, 'pointermove'],
        ['move', 784, 333, 1431, 'mousemove'],
        ['move', 774, 349, 1439, 'pointermove'],
        ['move', 762, 366, 1447, 'pointermove'],
        ['move', 747, 383, 1456, 'pointermove'],
        ['move', 738, 395, 1464, 'pointermove'],
        ['move', 729, 402, 1472, 'pointermove'],
        ['move', 722, 408, 1480, 'pointermove'],
        ['move', 713, 415, 1487, 'pointermove'],
        ['move', 712, 414, 1488, 'mousemove'],
        ['move', 708, 419, 1496, 'pointermove'],
        ['move', 702, 423, 1503, 'pointermove'],
        ['move', 701, 423, 1504, 'mousemove'],
        ['move', 696, 430, 1512, 'pointermove'],
        ['move', 691, 434, 1520, 'pointermove'],
        ['move', 690, 437, 1528, 'pointermove'],
        ['move', 686, 439, 1535, 'pointermove'],
        ['move', 685, 439, 1536, 'mousemove'],
        ['move', 682, 443, 1543, 'pointermove'],
        ['move', 678, 447, 1552, 'pointermove'],
        ['move', 675, 448, 1560, 'pointermove'],
        ['move', 672, 451, 1568, 'pointermove'],
        ['move', 667, 455, 1576, 'pointermove'],
        ['move', 663, 458, 1584, 'pointermove'],
        ['move', 660, 459, 1591, 'pointermove'],
        ['move', 660, 459, 1592, 'mousemove'],
        ['move', 658, 461, 1599, 'pointermove'],
        ['move', 656, 463, 1608, 'pointermove'],
        ['move', 654, 465, 1615, 'pointermove'],
        ['move', 652, 467, 1623, 'pointermove'],
        ['move', 652, 467, 1624, 'mousemove'],
        ['move', 651, 469, 1631, 'pointermove'],
        ['move', 650, 471, 1640, 'pointermove'],
        ['move', 650, 471, 1817, 'pointermove'],
        ['move', 650, 471, 1905, 'pointermove'],
        ['move', 650, 471, 1921, 'pointermove'],
        ['move', 650, 471, 1922, 'mousemove'],
        ['move', 651, 471, 1929, 'pointermove'],
        ['move', 653, 471, 1938, 'pointermove'],
        ['move', 654, 471, 1945, 'pointermove'],
    ]
    update_track_dt(t, click_track3)
    # ['down', 654, 471, 2026, 'pointerdown'],
    # ['up', 654, 471, 2096, 'pointerup'],  # 151

    click_track4 = [
        ['move', 655, 471, 2119, 'pointermove'],
        ['move', 656, 471, 2127, 'pointermove'],
        ['move', 658, 471, 2143, 'pointermove'],
        ['move', 662, 471, 2151, 'pointermove'],
        ['move', 666, 471, 2159, 'pointermove'],
        ['move', 674, 470, 2168, 'pointermove'],
        ['move', 680, 469, 2175, 'pointermove'],
        ['move', 687, 469, 2183, 'pointermove'],
        ['move', 697, 469, 2191, 'pointermove'],
        ['move', 707, 469, 2198, 'pointermove'],
        ['move', 716, 469, 2206, 'pointermove'],
        ['move', 726, 468, 2215, 'pointermove'],
        ['move', 735, 468, 2222, 'pointermove'],
        ['move', 745, 468, 2230, 'pointermove'],
        ['move', 747, 468, 2238, 'pointermove'],
        ['move', 751, 468, 2247, 'pointermove'],
        ['move', 761, 468, 2254, 'pointermove'],
        ['move', 770, 468, 2262, 'pointermove'],
        ['move', 778, 468, 2270, 'pointermove'],
        ['move', 785, 468, 2279, 'pointermove'],
        ['move', 792, 468, 2286, 'pointermove'],
        ['move', 796, 468, 2295, 'pointermove'],
        ['move', 800, 468, 2303, 'pointermove'],
        ['move', 803, 468, 2312, 'pointermove'],
        ['move', 806, 468, 2320, 'pointermove'],
        ['move', 809, 468, 2328, 'pointermove'],
        ['move', 810, 468, 2336, 'pointermove'],
        ['move', 812, 468, 2344, 'pointermove'],
        ['move', 814, 468, 2353, 'pointermove'],
        ['move', 815, 468, 2368, 'pointermove'],
        ['move', 817, 468, 2384, 'pointermove'],
        ['move', 818, 468, 2392, 'pointermove'],
        ['move', 818, 468, 2399, 'pointermove'],
        ['move', 819, 468, 2408, 'pointermove'],
        ['move', 820, 468, 2416, 'pointermove'],
        ['move', 822, 468, 2431, 'pointermove'],
        ['move', 822, 468, 2432, 'mousemove'],
        ['move', 824, 468, 2480, 'pointermove'],
        ['move', 826, 468, 2496, 'pointermove'],
        ['move', 827, 468, 2504, 'pointermove'],
        ['move', 829, 467, 2512, 'pointermove'],
        ['move', 830, 467, 2520, 'pointermove'],
        ['move', 831, 467, 2528, 'pointermove'],
    ]
    update_track_dt(t, click_track4)
    # ['down', 831, 467, 2611, 'pointerdown'],
    # ['up', 831, 467, 2696, 'pointerup'],

    click_track5 = [
        ['move', 831, 468, 0, 'pointermove'],
        ['move', 831, 469, 7, 'pointermove'],
        ['move', 831, 471, 17, 'pointermove'],
        ['move', 831, 474, 25, 'pointermove'],
        ['move', 831, 475, 33, 'pointermove'],
        ['move', 831, 474, 34, 'mousemove'],
        ['move', 833, 479, 41, 'pointermove'],
        ['move', 835, 485, 50, 'pointermove'],
        ['move', 836, 489, 57, 'pointermove'],
        ['move', 838, 494, 65, 'pointermove'],
        ['move', 838, 498, 72, 'pointermove'],
        ['move', 844, 504, 80, 'pointermove'],
        ['move', 850, 515, 87, 'pointermove'],
        ['move', 850, 515, 88, 'mousemove'],
        ['move', 857, 524, 96, 'pointermove'],
        ['move', 860, 530, 104, 'pointermove'],
        ['move', 861, 532, 111, 'pointermove'],
        ['move', 860, 532, 112, 'mousemove'],
        ['move', 862, 535, 120, 'pointermove'],
        ['move', 862, 535, 121, 'mousemove'],
        ['move', 862, 539, 128, 'pointermove'],
        ['move', 862, 543, 136, 'pointermove'],
        ['move', 862, 546, 144, 'pointermove'],
        ['move', 863, 549, 152, 'pointermove'],
        ['move', 864, 551, 159, 'pointermove'],
        ['move', 864, 552, 168, 'pointermove'],
        ['move', 864, 555, 175, 'pointermove'],
        ['move', 864, 555, 176, 'mousemove'],
        ['move', 864, 556, 184, 'pointermove'],
        ['move', 864, 557, 192, 'pointermove'],
        ['move', 866, 558, 216, 'pointermove'],
        ['move', 866, 558, 271, 'pointermove'],
        ['move', 866, 559, 281, 'pointermove'],
        ['move', 866, 561, 296, 'pointermove'],
        ['move', 866, 563, 313, 'pointermove'],
        ['move', 867, 563, 320, 'pointermove'],
        ['move', 867, 564, 328, 'pointermove'],
        ['move', 867, 565, 336, 'pointermove'],
        ['move', 868, 566, 352, 'pointermove']
    ]
    # update_track_dt(t, click_track5)
    # ['down', 868, 566, 3171, 'pointerdown'],
    # ['focus', 3172],
    # ['move', 868, 567, 3206, 'pointermove'],
    # ['up', 868, 567, 3239, 'pointerup']  # 143

    len_point_list = len(point_list)
    click_track = []
    for idx, point in enumerate(point_list):
        x = ca[idx]['x']
        y = ca[idx]['y']
        dt = dt_list[idx]
        down_t = t + dt - random.randint(70, 85)
        if idx == 0:
            tracks = [
                ['down', x, y, down_t, 'pointerdown'],
                ['up', x, y, t + dt, 'pointerup'],

            ]
            click_track.extend([*click_track1, *tracks])

        elif idx == 1:
            tracks = [
                ['down', x, y, t + dt - random.randint(70, 85), 'pointerdown'],
                ['up', x, y, t + dt, 'pointerup'],
            ]

            click_track.extend([*click_track2, *tracks])
        elif idx == 2:
            tracks = [
                ['down', x, y, t + dt - random.randint(70, 85), 'pointerdown'],
                ['up', x, y, t + dt, 'pointerup'],
            ]
            click_track.extend([*click_track3, *tracks])
        elif idx == 3:
            tracks = [
                ['down', x, y, t + dt - random.randint(70, 85), 'pointerdown'],
                ['up', x, y, t + dt, 'pointerup'],
            ]
            click_track.extend([*click_track4, *tracks])
        else:
            raise Exception(f'需要点击的坐标大于4，请修改轨迹坐标：{point_list}')

    tracks = [
        ['down', ca[-1]['x'], ca[-1]['x'] - 1, t + dt_list[-1] - 68, 'pointerdown'],
        ['focus', t + ca[-1]['dt'] - 67],
        ['move', ca[-1]['x'], ca[-1]['y'], t + dt_list[-1] - random.randint(28, 38), 'pointermove'],
        ['up', ca[-1]['x'], ca[-1]['y'], t + dt_list[-1], 'pointerup']
    ]
    last_dt_inv = random.randint(40, 55)
    for i in click_track5:
        i[3] += click_track[-1][3] + last_dt_inv

    click_track.extend([*click_track5, *tracks])
    # passtime = sum([i['dt'] for i in ca[1:]]) + 10
    passtime = dt_list[-1] - dt_list[0]
    params = {
        'ca': ca,
        'point_str': point_str,
        'pic': getphp_pic,
        'passtime': passtime,
        'c': getphp_c,
        's': getphp_s,
        'gt': gt,
        'challenge': challenge,
        'random16Key': random16Key,
        'click_track': click_track
    }
    # print(params)
    w3 = ctx.call('generateClickW3', params)
    logger.info(w3)

    url = "https://api.geevisit.com/ajax.php"
    params = {
        "gt": gt,
        "challenge": challenge,
        "lang": "zh-cn",
        "pt": "0",
        "client_type": "web",
        "w": w3,
        "callback": "geetest_" + get_now()
    }
    res = session.get(url, params=params)
    data = get_jsonp(res.text)
    return data


def main():
    ss = get_session()
    random16Key = get16randomStr(16)

    gt, challenge = ft_register_slide(ss)
    # gt: 6216680937717fdab947ed9e71a3aaa1
    logger.info(f"1 register_slide获取gt: {gt}  challenge: {challenge}")
    time.sleep(2)

    getphp_data = ft_get_php(ss, gt=gt, challenge=challenge, random16Key=random16Key)
    c, s = getphp_data['data']['c'], getphp_data['data']['s']
    logger.info(f'1.2 get.php获取c: {c}   s: {s}')  # c: [12, 58, 98, 36, 43, 95, 62, 15, 12]   s: 2a6e744e
    time.sleep(2)

    # ********** 点击验证按钮  **********
    ss.headers['host'] = 'api.geevisit.com'
    ajax_data = sc_ajax(ss, gt=gt, challenge=challenge, c=c, s=s, random16Key=random16Key)
    logger.info(f'2 ajax.php获取 {ajax_data}')  # {'status': 'success', 'data': {'result': 'slide'}}

    getphp_data = sc_get_php(ss, gt=gt, challenge=challenge)
    dict_data = getphp_data['data']
    getphp_c = dict_data['c']
    getphp_s = dict_data['s']
    pic_url = dict_data['pic']
    logger.info(f'2.2 get.php获取 {getphp_data}')

    # 下载滑块验证码图片
    static_url = "https://static.geetest.com"
    click_pic_url = urljoin(static_url, pic_url)
    download_img("click.jpg", click_pic_url)

    # ********** 三.点击验证码  **********
    # time.sleep(3)
    ajaxphp_data = td_ajax_php(ss, gt, challenge, getphp_c, getphp_s, pic_url, random16Key=random16Key)
    # {'status': 'error', 'error': 'not userresponse', 'user_error': '网络不给力', 'error_code': 'error_13'}
    logger.success(f'3. ajax.php获取validate: {ajaxphp_data}')


if __name__ == '__main__':
    main()
    # point_list = get_x()  # "5496_1815,5286_5774"
    # point_list = [(177, 169), (266, 227)]
    # point_list = [str(int(x / 333.75 * 10000)) +'_' + str(int(y / 333.75 * 10000)) for x, y in point_list]
    # point_str = ','.join(point_list)
    # print(point_str)
